package com.kerbores.blog.module;

import org.nutz.ioc.loader.annotation.Inject;
import org.nutz.mvc.View;
import org.nutz.mvc.annotation.At;
import org.nutz.mvc.annotation.Param;

import com.kerbores.blog.bean.Comment;
import com.kerbores.blog.module.common.BaseModule;
import com.kerbores.blog.service.ICommentService;

/**
 * @author Ixion <br>
 *         create at 2014年11月1日
 */
@At("comment")
public class CommentModule extends BaseModule {
	@Inject
	private ICommentService commentService;

	@At("/submit")
	public View submit(@Param("..") Comment comment) {
		if (_ip().indexOf("220.181.165") >= 0) {// 百度检测的ip我不让你提交,不然俺的博客就被评论得乱八七糟的了!!
			return _renderRedirct("/article/detail/" + comment.getArticleId());
		}
		comment.setUserId(_loginUserId());
		commentService.submit(comment);
		return _renderRedirct("/article/detail/" + comment.getArticleId());
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see com.kerbores.blog.module.common.BaseModule#_getNameSpace()
	 */
	@Override
	public String _getNameSpace() {
		return "comment";
	}

}
